#include <stdio.h>
#include <stdlib.h>
#include <float.h>



#define INT_MAX ((int)(~0U>>1))
#define INT_MIN (-INT_MAX - 1)
#define UINT_MAX (~0U)
#define LONG_MAX ((long)(~0UL>>1))
#define LONG_MIN (-LONG_MAX - 1)
#define ULONG_MAX (~0UL)
#define LLONG_MAX ((long long)(~0ULL>>1))
#define LLONG_MIN (-LLONG_MAX - 1)
#define ULLONG_MAX (~0ULL)


int main(void)
{

	unsigned char uc_0 = 126;
	unsigned char uc_2 = 254;
	unsigned long long ll1 = 0;
	unsigned int ii = 0;
	unsigned char cc = 0;
	unsigned char mul = 2;
	//ii = (1<<32)-1;
	//ii = 4294967295;

	printf("uc_0=%#08x,uc_2=%#08x\n",uc_0, uc_2);
	printf("(char )uc_2-(char )uc_0=%d\n",(char)uc_2 - (char)uc_0);
	printf("(char )(uc_2-uc_0)=%d\n",(char)(uc_2 - uc_0));

	ii = (~0U);
	printf("ii=%u, hex type=%#08x, (unsigned long long)ii=%#018llx\n",ii, ii, (unsigned long long)ii);
	ll1 = (unsigned long long)ii * mul; //KERNEL 里面有一些很大的数 ，尤其要注意。 

	//ll1 = (unsigned long long)(ii * mul); //这个就是错误的， 溢出了。 自己试试,得到的value就是0 了。 
	//ll1 = (unsigned long long)(ii *2); //error ,overlow
	//ll1 = ii *2;//the same above


	cc = ii; //only get the low 8 bits

	printf("ll1=%llu, hex type=%#018llx\n",ll1, ll1);
	printf("cc=%u\n",cc);
	printf("cc=%hhu\n",cc); //the result is same to above


	printf("LONG_MAX=%ld, hex type=%#08lx\n",LONG_MAX,LONG_MAX);
	printf("ULONG_MAX=%lu , hex type=%#08lx\n",ULONG_MAX,ULONG_MAX);
	printf("ULLONG_MAX=%llu , hex type=%#08llx\n",ULLONG_MAX,ULLONG_MAX);

	if (-2147483648 > 0)     printf("positive\n");
	if (-2147483647 - 1 < 0) printf("negative\n");
	if (INT_MIN == -INT_MIN) printf("equal\n");
	if (FLT_MIN > 0)         printf("floating\n");
				 
	return 0;
}

